using SqlSugar;
using System;
using System.Collections.Generic;

namespace B.S.XZYData.Domain.ZSH
{
	/// <summary>
	/// 报工主表
	/// </summary>
	[SugarTable("WorkReport")]
	public class WorkReport
	{
		/// <summary>
		/// 主键，自增
		/// </summary>
		[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
		public int Id { get; set; }

		/// <summary>
		/// 工单业务编码（关联工单主表）
		/// </summary>
		[SugarColumn(Length = 50, IsNullable = false)]
		public string WorkOrderCode { get; set; }

		/// <summary>
		/// 工序名称（字典关联）
		/// </summary>
		[SugarColumn(Length = 100, IsNullable = false)]
		public string ProcessName { get; set; }

		/// <summary>
		/// 产品主数据编码
		/// </summary>
		[SugarColumn(Length = 50, IsNullable = false)]
		public string ProductCode { get; set; }

		/// <summary>
		/// 产品编号（可与编码一致，用于追踪）
		/// </summary>
		[SugarColumn(Length = 50, IsNullable = true)]
		public string ProductNo { get; set; }

		/// <summary>
		/// 产品名称
		/// </summary>
		[SugarColumn(Length = 100, IsNullable = true)]
		public string ProductName { get; set; }

		/// <summary>
		/// 产品规格
		/// </summary>
		[SugarColumn(Length = 200, IsNullable = true)]
		public string ProductSpec { get; set; }

		/// <summary>
		/// 报工数量
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public int ReportQty { get; set; }

		/// <summary>
		/// 生产人员（关联员工表）
		/// </summary>
		[SugarColumn(Length = 50, IsNullable = false)]
		public string Producer { get; set; }

		/// <summary>
		/// 计量单位（件、个等）
		/// </summary>
		[SugarColumn(Length = 20, IsNullable = true)]
		public string Unit { get; set; }

		/// <summary>
		/// 良品数量
		/// </summary>
		public int GoodQty { get; set; }

		/// <summary>
		/// 不良品数量
		/// </summary>
		public int DefectiveQty { get; set; }

		/// <summary>
		/// 工序状态
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public ProcessStatusEnum ProcessStatus { get; set; }

		/// <summary>
		/// 进度描述（如：50%）
		/// </summary>
		[SugarColumn(Length = 50, IsNullable = true)]
		public string ProcessProgress { get; set; }

		/// <summary>
		/// 开始时间
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public DateTime StartTime { get; set; }

		/// <summary>
		/// 结束时间（可空）
		/// </summary>
		[SugarColumn(IsNullable = true)]
		public DateTime? EndTime { get; set; }

		/// <summary>
		/// 报工耗时（小时）
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public decimal ReportHours { get; set; }

		/// <summary>
		/// 报工耗时（分钟）
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public int ReportMinutes { get; set; }

		/// <summary>
		/// 标准效率（产量/时间）
		/// </summary>
		public decimal StandardEfficiency { get; set; }

		/// <summary>
		/// 实际效率（产量/时间）
		/// </summary>
		public decimal ActualEfficiency { get; set; }

		/// <summary>
		/// 达标率（实际/标准*100%）
		/// </summary>
		public decimal ComplianceRate { get; set; }

		/// <summary>
		/// 计价方式（计件/计时）
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public PricingMethodEnum PricingMethod { get; set; }

		/// <summary>
		/// 工资单价
		/// </summary>
		public decimal WageUnitPrice { get; set; }

		/// <summary>
		/// 预计工资（报工数*单价）
		/// </summary>
		public decimal EstimatedWage { get; set; }

		/// <summary>
		/// 奖励金额
		/// </summary>
		public decimal BonusAmount { get; set; }

		/// <summary>
		/// 处罚金额
		/// </summary>
		public decimal PenaltyAmount { get; set; }

		/// <summary>
		/// 不良品项明细（子表）
		/// </summary>
		[SugarColumn(IsIgnore = true)]
		public List<WorkReportDefectiveItem> DefectiveItems { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 创建人ID（关联User.Id）
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public int CreatorId { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public DateTime? ModifyTime { get; set; }

        /// <summary>
        /// 最后修改人ID（关联User.Id）
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? ModifierId { get; set; }

		/// <summary>
		/// 伪删除标记（false=未删除，true=已删除）
		/// </summary>
		[SugarColumn(IsNullable = false)]
		public bool IsDeleted { get; set; } = false;
    }

	/// <summary>
	/// 工序状态
	/// </summary>
	public enum ProcessStatusEnum : byte
	{
		/// <summary>
		/// 未开始
		/// </summary>
		NotStarted = 0,
		/// <summary>
		/// 进行中
		/// </summary>
		InProgress = 1,
		/// <summary>
		/// 已完成
		/// </summary>
		Completed = 2
	}

	/// <summary>
	/// 计价方式
	/// </summary>
	public enum PricingMethodEnum : byte
	{
		/// <summary>
		/// 按件计价
		/// </summary>
		ByPiece = 0,
		/// <summary>
		/// 按小时计价
		/// </summary>
		ByHour = 1
	}
}


